import UICore from "../../../../Core/Res/UICore";
import { ViewManager } from "../../base/ViewManager";
import { GameModels } from "../../socket/GameModels";
import AbstractUIWindow from "../../window/AbstractUIWindow";

import * as fgui from "fairygui-cc";

export class TestWindow extends AbstractUIWindow {

    private addItem: fgui.GButton;
    private iteminput: fgui.GTextInput;
    protected getResList(): Array<string> {
        return ["Main"];
    }
    protected onInit(): void {
        this._view = UICore.createObject("Main", "TestWindow").asCom;
    }
    protected onShow(): void {
        this.addItem.onClick(this.clickaddItem, this);
    }
    private clickaddItem(): void {
        if (!this.iteminput.text) {
            ViewManager.ins.showtips("参数格式不对");
            return;
        }
        const param: string[] = this.iteminput.text.split(` `);
        if (param.length != 2) {
            ViewManager.ins.showtips("参数格式不对");
            return;
        }
        GameModels.lobby.send_ReqGM(`ADDItem`, param);
    }
}